import request from '@utils/request'

// 创建获取商品分类接口数据函数
const fetchCates = (params = {}) => request.get('shop/goods/category/all', {
  params
})

// 创建获取首页轮播图分类数据接口
const fetchHomeBanner = (params = {}) => request.get('/banner/list', {
  params
})

// 获取推荐商品列表数据
const fetchRecGoods = (params = {}) => request.post('shop/goods/list/v2', params)

// 创建请求商品详情数据接口
const fetchDetails = (id) => request.get('/shop/goods/detail', {
  params: {
    id
  }
})

// 创建加入购物车接口数据
const addCart = (params = {}) => request.post('/shopping-cart/add', params)

// 创建用户注册接口
const regName = (params = {}) => request.post('/user/username/register', params)

// 创建用户登录接口
const userLogin = (params = {}) => request.post('/user/username/login', params)

// 创建读取购物车数据接口
const getCart = (params = {}) => request.get('/shopping-cart/info', {
  params
})

// 创建修改购物车商品数量接口
const changeCart = (params = {}) => request.post('/shopping-cart/modifyNumber', params)

// 移除购物车商品接口
const removeCart = (params = {}) => request.post('/shopping-cart/remove', params)

// 修改购物车选中状态
const changeCartChecked = (params = {}) => request.post('/shopping-cart/select', params)

// 添加收货地址
const addLinkman = (params = {}) => request.post('/user/shipping-address/add', params)

// 收获地址列表
const showLinkmanAdd = (params = {}) => request.post('/user/shipping-address/list/v2', params)

// 编辑联系人接口
const editLinkmen = (params = {}) => request.post('/user/shipping-address/update', params)

// 获取默认收货地址详情
const defaultLinkman = (params = {}) => request.get('/user/shipping-address/detail/v2', {
  params
})

// 删除联系人
const delLinkman = (params = {}) => request.post('/user/shipping-address/delete', params)

// 获取默认联系人
const defLinkman = (params = {}) => request.get('/user/shipping-address/default/v2', {
  params
})

export {
  fetchCates,
  fetchHomeBanner,
  fetchRecGoods,
  fetchDetails,
  addCart,
  regName,
  userLogin,
  getCart,
  changeCart,
  removeCart,
  changeCartChecked,
  addLinkman,
  showLinkmanAdd,
  editLinkmen,
  defaultLinkman,
  delLinkman,
  defLinkman
}
